package org.jeecg.modules.htxincailiao.address.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.htxincailiao.address.domain.vo.HTAddressVO;
import org.jeecg.modules.htxincailiao.address.entity.HTBuyerAddress;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
 * @Description: ht_buyer_address
 * @Author: jeecg-boot
 * @Date:   2021-06-25
 * @Version: V1.0
 */
public interface HTBuyerAddressMapper extends BaseMapper<HTBuyerAddress> {

    @Select("<script>" +
            "SELECT TT.*,area.name districtName FROM (" +
            "SELECT T.*,area.name cityName FROM (" +
            "SELECT address.*,area.name provinceName FROM " +
            "ht_buyer_address AS address,ht_area AS area " +
            "WHERE address.province_id=area.id AND address.id=#{addressId}) AS T,ht_area AS area " +
            "WHERE T.city_id=area.id) AS TT,ht_area AS area " +
            "WHERE TT.district_id=area.id" +
            "</script>")
    HTAddressVO queryByAddressId(@Param("addressId") String addressId);


    @Select("<script>" +
            "SELECT * FROM ht_buyer_address WHERE is_default=#{isDefault}" +
            "</script>")
    List<HTBuyerAddress> findAllByIsDefault(@Param("isDefault") Integer isDefault);
}
